package com.lhp.smp.test01.controller;

import com.lhp.smp.test01.pojo.Role;
import com.lhp.smp.test01.pojo.User;
import com.lhp.smp.test01.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {
    @Resource
    private UserService userService;
    @RequestMapping("/user/queryall")
    public List<User> queryAll(){
        return userService.list();
    }
    @RequestMapping("/user/add")
    public String add(){
        User user = new User(1,"sdjfi","sdf","iwei");
        userService.save(user);
        return "success";
    }
    @RequestMapping("/user/update")
    public String update(){
        User user = new User(1,"sss","sdf","iwei");
        userService.updateById(user);
        return "success";
    }
    @RequestMapping("/user/delete")
    public String delete(){
        userService.removeById(1);
        return "success";
    }
}
